oParty = oUF:NewModule("oUF_Party")
local M = DongleStub("MetrognomeNano")
local G = getfenv(0)

ShowPartyFrame = function() oParty:disableBlizzard() end

function oParty:Enable()
	for i=1,4 do
                self:disableBlizzard()
		oUF.unit["party"..i] = oUF.class.unit:new("party"..i)
		oUF.unit["party"..i]:loadPosition()
		
		-- Pet Stuff Oo
		--oUF.unit["partypet"..i] = oUF.class.unit:new("partypet"..i)
		--oUF.unit["partypet"..i]:loadPosition()
		
		-- Events!
		self:RegisterEvent("PARTY_MEMBERS_CHANGE", "disableBlizzard")
		self:RegisterEvent("RAID_ROSTER_UPDATE", "disableBlizzard")
		--self:RegisterEvent("UNIT_PET", "updatePet")
		
		M:Register(self, "hideblizz", function() self:disableBlizzard() end, .1)
	end
end

function oParty:disableBlizzard()
	M:Start("hideblizz", 10)
	for i=1,4 do
		if G["PartyMemberFrame"..i]:IsShown() then
			M:Stop("hideblizz")
			G["PartyMemberFrame"..i]:Hide()
			G["PartyMemberFrame"..i]:UnregisterAllEvents()
			G["PartyMemberFrame"..i.."PetFrame"]:Hide()
			G["PartyMemberFrame"..i.."PetFrame"]:UnregisterAllEvents()
		end
	end
end

function oParty:updatePet()
	for i = 1, 4 do
		oUF.unit["partypet"..i]:updateAll()
	end
end
